import Vue from "vue"
import Vuex from "vuex"
Vue.use(Vuex)
const store = new Vuex.Store({
    state: {
      user:{
          uname:sessionStorage.getItem("uanme")|"",
          realname:sessionStorage.getItem("realname")|"",
      }
    },
    mutations: {
      setUser (state,user) {
        //   获取传递的参数，给state的user赋值
        state.user=user;
        // 将获取的值保存到回话存储中，方便下次的使用
        sessionStorage.setItem("uname",user.uname),
        sessionStorage.setItem("realname",user.realname)
      }
    }
  });

//   将store对象暴露出去
export default store;